home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / SASC_6.0_Disk_4.adf / Compiler_Headers / Include / libraries / configregs.h < prev    next >
C/C++ Source or Header  |  1992-07-30  |  10KB  |  285 lines

  1. #ifndef LIBRARIES_CONFIGREGS_H
  2. #define LIBRARIES_CONFIGREGS_H
  3. /*
  4. **    $Filename: libraries/configregs.h $
  5. **    $Release: 2.04 Includes, V37.4 $
  6. **    $Revision: 36.13 $
  7. **    $Date: 91/02/15 $
  8. **
  9. **    AutoConfig (tm) hardware register and bit definitions
  10. **
  11. **    (C) Copyright 1985-1991 Commodore-Amiga, Inc.
  12. **        All Rights Reserved
  13. */
  14.  
  15.  
  16. #ifndef EXEC_TYPES_H
  17. #include "exec/types.h"
  18. #endif    /* EXEC_TYPES_H */
  19.  
  20.  
  21. /*
  22. ** AutoConfig (tm) boards each contain a 32 byte "ExpansionRom" area that is
  23. ** read by the system software at configuration time.  Configuration of each
  24. ** board starts when the ConfigIn* signal is passed from the previous board
  25. ** (or from the system for the first board).  Each board will present it's
  26. ** ExpansionRom structure at location $00E80000 to be read by the system.
  27. ** This file defines the appearance of the ExpansionRom area.
  28. **
  29. ** Expansion boards are actually organized such that only one nybble per
  30. ** 16 bit word contains valid information.  The low nybbles of each
  31. ** word are combined to fill the structure below. (This table is structured
  32. ** as LOGICAL information.  This means that it never corresponds exactly
  33. ** with a physical implementation.)
  34. **
  35. ** The ExpansionRom space is further split into two regions:  The first 16
  36. ** bytes are read-only.  Except for the er_type field, this area is inverted
  37. ** by the system software when read in.  The second 16 bytes contain the
  38. ** control portion, where all read/write registers are located.
  39. **
  40. ** The system builds one "ConfigDev" structure for each board found.  The
  41. ** list of boards can be examined using the expansion.library/FindConfigDev
  42. ** function.
  43. **
  44. ** A special "hacker" Manufacturer ID number is reserved for test use:
  45. ** 2011 ($7DB).  When inverted this will look like $F824.
  46. */
  47.  
  48. struct ExpansionRom {        /* -First 16 bytes of the expansion ROM */
  49.     UBYTE    er_Type;    /* Board type, size and flags */
  50.     UBYTE    er_Product;    /* Product number, assigned by manufacturer */
  51.     UBYTE    er_Flags;    /* Flags */
  52.     UBYTE    er_Reserved03;    /* Must be zero ($ff inverted) */
  53.     UWORD    er_Manufacturer; /* Unique ID,ASSIGNED BY COMMODORE-AMIGA! */
  54.     ULONG    er_SerialNumber; /* Available for use by manufacturer */
  55.     UWORD    er_InitDiagVec; /* Offset to optional "DiagArea" structure */
  56.     UBYTE    er_Reserved0c;
  57.     UBYTE    er_Reserved0d;
  58.     UBYTE    er_Reserved0e;
  59.     UBYTE    er_Reserved0f;
  60. };
  61.  
  62.  
  63. /*
  64. ** Note that use of the ec_BaseAddress register is tricky.  The system
  65. ** will actually write twice.  First the low order nybble is written
  66. ** to the ec_BaseAddress register+2 (D15-D12).    Then the entire byte is
  67. ** written to ec_BaseAddress (D15-D8).    This allows writing of a byte-wide
  68. ** address to nybble size registers.
  69. */
  70.  
  71. struct ExpansionControl {    /* -Second 16 bytes of the expansion ROM */
  72.     UBYTE    ec_Interrupt;    /* Optional interrupt control register */
  73.     UBYTE    ec_Z3_HighBase; /* Zorro III   : Config address bits 24-31 */
  74.     UBYTE    ec_BaseAddress; /* Zorro II/III: Config address bits 16-23 */
  75.     UBYTE    ec_Shutup;    /* The system writes here to shut up a board */
  76.     UBYTE    ec_Reserved14;
  77.     UBYTE    ec_Reserved15;
  78.     UBYTE    ec_Reserved16;
  79.     UBYTE    ec_Reserved17;
  80.     UBYTE    ec_Reserved18;
  81.     UBYTE    ec_Reserved19;
  82.     UBYTE    ec_Reserved1a;
  83.     UBYTE    ec_Reserved1b;
  84.     UBYTE    ec_Reserved1c;
  85.     UBYTE    ec_Reserved1d;
  86.     UBYTE    ec_Reserved1e;
  87.     UBYTE    ec_Reserved1f;
  88. };
  89.  
  90. /*
  91. ** many of the constants below consist of a triplet of equivalent
  92. ** definitions: xxMASK is a bit mask of those bits that matter.
  93. ** xxBIT is the starting bit number of the field.  xxSIZE is the
  94. ** number of bits that make up the definition.    This method is
  95. ** used when the field is larger than one bit.
  96. **
  97. ** If the field is only one bit wide then the xxB_xx and xxF_xx convention
  98. ** is used (xxB_xx is the bit number, and xxF_xx is mask of the bit).
  99. */
  100.  
  101. /* manifest constants */
  102. #define E_SLOTSIZE        0x10000
  103. #define E_SLOTMASK        0xffff
  104. #define E_SLOTSHIFT        16
  105.  
  106. /* these define the free regions of Zorro memory space.
  107. ** THESE MAY WELL CHANGE FOR FUTURE PRODUCTS!
  108. */
  109. #define E_EXPANSIONBASE    0x00e80000    /* Zorro II  config address */
  110. #define EZ3_EXPANSIONBASE    0xff000000    /* Zorro III config address */
  111.  
  112. #define E_EXPANSIONSIZE    0x00080000    /* Zorro II  I/O type cards */
  113. #define E_EXPANSIONSLOTS    8
  114.  
  115. #define E_MEMORYBASE        0x00200000    /* Zorro II  8MB space */
  116. #define E_MEMORYSIZE        0x00800000
  117. #define E_MEMORYSLOTS        128
  118.  
  119. #define EZ3_CONFIGAREA        0x40000000    /* Zorro III space */
  120. #define EZ3_CONFIGAREAEND    0x7FFFFFFF    /* Zorro III space */
  121. #define EZ3_SIZEGRANULARITY    0x00080000    /* 512K increments */
  122.  
  123.  
  124.  
  125. /**** er_Type definitions (ttldcmmm) ***************************************/
  126.  
  127. /* er_Type board type bits -- the OS ignores "old style" boards */
  128. #define ERT_TYPEMASK        0xc0    /* Bits 7-6 */
  129. #define ERT_TYPEBIT        6
  130. #define ERT_TYPESIZE        2
  131. #define ERT_NEWBOARD        0xc0
  132. #define ERT_ZORROII        ERT_NEWBOARD
  133. #define ERT_ZORROIII        0x80
  134.  
  135. /* other bits defined in er_Type */
  136. #define ERTB_MEMLIST        5   /* Link RAM into free memory list */
  137. #define ERTB_DIAGVALID        4   /* ROM vector is valid */
  138. #define ERTB_CHAINEDCONFIG    3   /* Next config is part of the same card */
  139.  
  140. #define ERTF_MEMLIST        (1<<5)
  141. #define ERTF_DIAGVALID        (1<<4)
  142. #define ERTF_CHAINEDCONFIG    (1<<3)
  143.  
  144. /* er_Type field memory size bits */
  145. #define ERT_MEMMASK        0x07    /* Bits 2-0 */
  146. #define ERT_MEMBIT        0
  147. #define ERT_MEMSIZE        3
  148.  
  149.  
  150.  
  151. /**** er_Flags byte -- for those things that didn't fit into the type byte ****/
  152. /**** the hardware stores this byte in inverted form               ****/
  153. #define ERFF_MEMSPACE        (1<<7)    /* Wants to be in 8 meg space. */
  154. #define ERFB_MEMSPACE        7    /* (NOT IMPLEMENTED) */
  155.  
  156. #define ERFF_NOSHUTUP        (1<<6)    /* Board can't be shut up */
  157. #define ERFB_NOSHUTUP        6
  158.  
  159. #define ERFF_EXTENDED        (1<<5)    /* Zorro III: Use extended size table */
  160. #define ERFB_EXTENDED        5    /*          for bits 0-2 of er_Type */
  161.                     /* Zorro II : Must be 0 */
  162.  
  163. #define ERFF_ZORRO_III        (1<<4)    /* Zorro III: must be 1 */
  164. #define ERFB_ZORRO_III        4    /* Zorro II : must be 0 */
  165.  
  166. #define ERT_Z3_SSMASK        0x0F    /* Bits 3-0.  Zorro III Sub-Size.  How */
  167. #define ERT_Z3_SSBIT        0    /* much space the card actually uses   */
  168. #define ERT_Z3_SSSIZE        4    /* (regardless of config granularity)  */
  169.                     /* Zorro II : must be 0           */
  170.  
  171.  
  172. /* ec_Interrupt register (unused) ********************************************/
  173. #define ECIB_INTENA        1
  174. #define ECIB_RESET        3
  175. #define ECIB_INT2PEND        4
  176. #define ECIB_INT6PEND        5
  177. #define ECIB_INT7PEND        6
  178. #define ECIB_INTERRUPTING    7
  179.  
  180. #define ECIF_INTENA        (1<<1)
  181. #define ECIF_RESET        (1<<3)
  182. #define ECIF_INT2PEND        (1<<4)
  183. #define ECIF_INT6PEND        (1<<5)
  184. #define ECIF_INT7PEND        (1<<6)
  185. #define ECIF_INTERRUPTING    (1<<7)
  186.  
  187.  
  188.  
  189. /* figure out amount of memory needed by this box/board */
  190. #define ERT_MEMNEEDED(t)    \
  191.     (((t)&ERT_MEMMASK)? 0x10000 << (((t)&ERT_MEMMASK) -1) : 0x800000 )
  192.  
  193. /* same as ERT_MEMNEEDED, but return number of slots */
  194. #define ERT_SLOTSNEEDED(t)    \
  195.     (((t)&ERT_MEMMASK)? 1 << (((t)&ERT_MEMMASK)-1) : 0x80 )
  196.  
  197.  
  198.  
  199. /* convert a expansion slot number into a memory address */
  200. #define EC_MEMADDR(slot)        ((slot) << (E_SLOTSHIFT) )
  201.  
  202. /* a kludge to get the byte offset of a structure */
  203. #define EROFFSET(er)    ((int)&((struct ExpansionRom *)0)->er)
  204. #define ECOFFSET(ec)    \
  205.  (sizeof(struct ExpansionRom)+((int)&((struct ExpansionControl *)0)->ec))
  206.  
  207.  
  208.  
  209. /***************************************************************************
  210. **
  211. ** these are the specifications for the diagnostic area.  If the Diagnostic
  212. ** Address Valid bit is set in the Board Type byte (the first byte in
  213. ** expansion space) then the Diag Init vector contains a valid offset.
  214. **
  215. ** The Diag Init vector is actually a word offset from the base of the
  216. ** board.  The resulting address points to the base of the DiagArea
  217. ** structure.  The structure may be physically implemented either four,
  218. ** eight, or sixteen bits wide.  The code will be copied out into
  219. ** ram first before being called.
  220. **
  221. ** The da_Size field, and both code offsets (da_DiagPoint and da_BootPoint)
  222. ** are offsets from the diag area AFTER it has been copied into ram, and
  223. ** "de-nibbleized" (if needed).  (In other words, the size is the size of
  224. ** the actual information, not how much address space is required to
  225. ** store it.)
  226. **
  227. ** All bits are encoded with uninverted logic (e.g. 5 volts on the bus
  228. ** is a logic one).
  229. **
  230. ** If your board is to make use of the boot facility then it must leave
  231. ** its config area available even after it has been configured.  Your
  232. ** boot vector will be called AFTER your board's final address has been
  233. ** set.
  234. **
  235. ****************************************************************************/
  236.  
  237. struct DiagArea {
  238.     UBYTE    da_Config;    /* see below for definitions */
  239.     UBYTE    da_Flags;    /* see below for definitions */
  240.     UWORD    da_Size;    /* the size (in bytes) of the total diag area */
  241.     UWORD    da_DiagPoint;    /* where to start for diagnostics, or zero */
  242.     UWORD    da_BootPoint;    /* where to start for booting */
  243.     UWORD    da_Name;    /* offset in diag area where a string */
  244.                 /*   identifier can be found (or zero if no */
  245.                 /*   identifier is present). */
  246.  
  247.     UWORD    da_Reserved01;    /* two words of reserved data.    must be zero. */
  248.     UWORD    da_Reserved02;
  249. };
  250.  
  251. /* da_Config definitions */
  252. /*
  253. ** DAC_BYTEWIDE can be simulated using DAC_NIBBLEWIDE.
  254. */
  255. #define DAC_BUSWIDTH    0xC0 /* two bits for bus width */
  256. #define DAC_NIBBLEWIDE    0x00
  257. #define DAC_BYTEWIDE    0x40 /* BUG: Will not work under V34 Kickstart! */
  258. #define DAC_WORDWIDE    0x80
  259.  
  260. #define DAC_BOOTTIME    0x30    /* two bits for when to boot */
  261. #define DAC_NEVER    0x00    /* obvious */
  262. #define DAC_CONFIGTIME    0x10    /* call da_BootPoint when first configing */
  263.                 /*   the device */
  264. #define DAC_BINDTIME    0x20    /* run when binding drivers to boards */
  265.  
  266. /*
  267. **
  268. ** These are the calling conventions for the diagnostic callback
  269. ** (from da_DiagPoint):
  270. **
  271. ** A7 -- points to at least 2K of stack
  272. ** A6 -- ExecBase
  273. ** A5 -- ExpansionBase
  274. ** A3 -- your board's ConfigDev structure
  275. ** A2 -- Base of diag/init area that was copied
  276. ** A0 -- Base of your board
  277. **
  278. ** Your board must return a value in D0.  If this value is NULL, then
  279. ** the diag/init area that was copied in will be returned to the free
  280. ** memory pool.
  281. */
  282.  
  283.  
  284. #endif /* LIBRARIES_CONFIGREGS_H */
  285.